package com.banyuan;


import com.banyuan.Utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

// 查询SQL语句
public class JDBCQuery {

    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement pstm = null;
        ResultSet rs = null;
        try {
             conn = JDBCUtils.getConnection();
             pstm = conn.prepareStatement("select * from person ");

             rs = pstm.executeQuery();
            while (rs.next()) {
                String username = rs.getString("username");
                System.out.println(username);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            JDBCUtils.close(rs);
            JDBCUtils.close(pstm);
            JDBCUtils.close(conn);
        }
    }

}
